{extend name="layout/layout" /}
<!--请在下方写此页面body相关内容-->
{block name="container"}
<article class="page-container">
	<form class="form form-horizontal" id="form" method="post" action="<?php url('category/categorySave')?>">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>分类名称：</label>
			<div class="formControls col-xs-8 col-sm-8">
				<input type="text" class="input-text" value="<?php echo $info['category_name']?>" placeholder="请输入分类名" id="category_name" name="category_name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上级分类：</label>
			<div class="formControls col-xs-8 col-sm-8"> <span class="select-box">
				<select class="select" name="pid" size="1">
					<option value="0">顶级分类</option>
					<?php if( !empty($list) ) { foreach( $list as $v ){ if( $v['deep'] == 0 ) {?>
					<option value="<?php echo $v['id']?>" <?php echo $v['id'] == $info['pid'] ? 'selected' : '' ?>><?php echo '-'.$v['category_name']?></option>
					<?php } if( $v['deep'] == 1 ) { ?>
					<option value="<?php echo $v['id']?>" <?php echo $v['id'] == $info['pid'] ? 'selected' : '' ?>><?php echo str_repeat('&nbsp', 4).'-'.$v['category_name'];?></option>
					<?php } } }?>
				</select>
			</span></div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-8 col-xs-offset-4 col-sm-offset-3">
				<input type="hidden" name="id" value="<?php echo $info['id']?>">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
{/block}
<!--请在上方方写此页面body相关内容-->

<!--请在下方写此页面业务相关的脚本-->
{block name="js"}
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-yellow',
		increaseArea: '20%'
	});
	$("#form").validate({
		rules:{
            category_name:{required:true},
			pid:{required:true},
		},
		submitHandler:function(form){
			var options = {
                beforeSubmit: function () {
                    load = layer.load();
                },
                success: function(obj){
                    if(obj.code !== 0){
                        layer.msg(obj.msg,{ icon:5, time:2000 });
                    } else {
                        layer.msg(obj.msg, { icon: 1, time: 1000 }, function(){
                            closeWindow();
                        });
                    }
                    layer.close(load);
                }
			};
			$(form).ajaxSubmit(options);
		}
	});
});
</script>
{/block}
<!--/请在上方写此页面业务相关的脚本-->